conn = require('../db/connectMysql');

function sep() {
    console.log('\n'+'*'.repeat(50)+'\n');
}

module.exports = {
    getSql:
    function (sesql) {
        var promise = new Promise(function (resolve, reject) {
            conn.query(sesql,(err, results)=>{
                if (results) {
                    resolve(results);
                }
                if (err) {
                    console.error('数据库操作出错');
                    reject(err);
                }
            });
        });
        promise.then(function (value) {
            // console.log(value);
            return value;
            // success
        }, function (value) {
            // failure
            console.error('promise error');sep();
        });
        return promise;
    }
}